Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PC-31471) test: add assert_num_queries in public #13820

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

blbpro
Copy link
Contributor

@blbpro blbpro commented Aug 26, 2024

But de la pull request

Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-31471

@blbpro blbpro force-pushed the PC-31471_assert_num_queries_in_public branch from 5208bc4 to 53e1b20 Compare August 26, 2024 15:31
@blbpro blbpro marked this pull request as ready for review August 26, 2024 17:12
@mageoffray mageoffray force-pushed the PC-31471_assert_num_queries_in_public branch 3 times, most recently from 7c2f4bb to 81c51b7 Compare September 3, 2024 07:00
Copy link
Contributor

@prouzet prouzet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avoue n'avoir que survolé la seconde moitié, car c'est un peu répétitif à lire :)

num_queries += 1 # select stock
num_queries += 1 # select venue
with testing.assert_num_queries(num_queries):
response = client.with_basic_auth(pro_user.email).get(url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention à pro_user.email, n'est-ce pas la raison de la première requête ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça ma étonné aussi mais non, je l'ai quand même sorti du assert_num_queries pour que visuellement on soit sûr qu'il n'ajoute pas de requête

@mageoffray mageoffray force-pushed the PC-31471_assert_num_queries_in_public branch 3 times, most recently from d84c4a4 to c38798f Compare September 3, 2024 11:47
Copy link
Contributor

@tcoudray-pass tcoudray-pass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quel est exactement le but recherché pour les assert_num_queries ?

Il me semble qu'il serait préférable de ne pas appliquer les assert_num_queries à tout les tests d'un endpoint parce que ça complexifie la lecture du test.

Je serais plutôt partisan d'avoir pour chaque endpoint un test dédié aux assert_num_queries sur un certain nombre de cas nominaux (200, 400, 404, 401) qui s'appellerait quelque chose comme test_num_queries. Ça permettrait d'alléger les autres tests qui s'occupent de tester la logique métier et de les rendre plus clairs. Ainsi si jamais ma modification a changé le nombre query, il n'y aurait qu'un test rouge et qu'un test à fixer (ça allègerait la PR).

Copy link
Contributor

@tcoudray-pass tcoudray-pass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mise à part les tests qui peuvent être retirés (parce que j'avais oublié de le faire 😇) 👍🏻

@mageoffray mageoffray force-pushed the PC-31471_assert_num_queries_in_public branch 4 times, most recently from 3d7bed0 to b14b32a Compare September 4, 2024 15:44
@mageoffray mageoffray force-pushed the PC-31471_assert_num_queries_in_public branch from b14b32a to ffc4d7b Compare September 4, 2024 16:14
@mageoffray mageoffray merged commit 453d0b1 into master Sep 5, 2024
23 checks passed
@mageoffray mageoffray deleted the PC-31471_assert_num_queries_in_public branch September 5, 2024 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants